package com.xmall.utils;

import com.xmall.define.base.Result;
import com.xmall.define.base.ResultCode;
import com.xmall.exception.XmallException;

import java.util.List;

public class XmallUtils {

    public static void notNull(Object object) {
        if(null == object) {
            throw new XmallException(ResultCode.NOT_EXIST);
        }
    }

    public static void notEmpty(List list) {
        if(null == list || list.size() == 0) {
            throw new XmallException(ResultCode.NOT_EXIST);
        }
    }

    public static void checkRemoteResult(Result result) {
        if(null == result || !result.callSuccess()) {
            throw new XmallException(ResultCode.REMOTE_REQUEST_ERROR);
        }
    }
}
